Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development


Using an extract program for a node

This section explains the requirements and precautions to take when you use an extract program to populate a dynamic TreeView’s nodes from an extraction program.

The extraction procedure mechanism was designed to allow developers to extract complex data from the database by allowing them to execute a procedure on an OpenEdgeŽ AppServer and send this back to the client side, indicating that the extraction program is dependant on being connected to a database, and the database tables could be directly referenced.

This example uses the customer table from the Sports2000 database.

To create an extraction procedure, you can create a new structured PLIP from the AppBuilder menu, as shown in Figure 9–7, or add a procedure to an existing structured PLIP.

Figure 9–7: New dialog box

In this PLIP you must add a procedure called loadData, shown in Figure 9–8.

Figure 9–8: Procedure loadData

This procedure accepts three input parameters and one input-output table handle to get and send the temp-table that is responsible for creating the nodes on the TreeView.

For this example, the extract program is run for the root node of the TreeView and it will return the first 10 customers in the database. The procedure will look as follows:

/*------------------------------------------------------------------------- 
  Purpose:     Extracts the first 10 customer records from the DataBase 
  Parameters:  <none> 
  Notes:        
-------------------------------------------------------------------------*/ 
DEFINE INPUT  PARAMETER pcParentNodeKey AS CHARACTER  NO-UNDO. 
DEFINE INPUT  PARAMETER pcPrimarySDO    AS CHARACTER  NO-UNDO. 
DEFINE INPUT  PARAMETER pcFilterValue   AS CHARACTER  NO-UNDO. 
DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE phTable.  
DEFINE VARIABLE hBuf                  AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hParentNodeKey        AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hNodeKey              AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hNodeLabel            AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hPrivateData          AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hRecordRef            AS HANDLE       NO-UNDO. 
DEFINE VARIABLE hRecordRowid          AS HANDLE       NO-UNDO. 
/* Grab the handles to the individual fields in the tree data table. */ 
ASSIGN hBuf           = phTable:DEFAULT-BUFFER-HANDLE 
       hParentNodeKey = hBuf:BUFFER-FIELD('parent_node_key':U) 
       hNodeKey       = hBuf:BUFFER-FIELD('node_key':U) 
       hNodeLabel     = hBuf:BUFFER-FIELD('node_label':U) 
       hPrivateData   = hBuf:BUFFER-FIELD('private_data':U) 
       hRecordRef     = hBuf:BUFFER-FIELD('record_ref':U) 
       hRecordRowid   = hBuf:BUFFER-FIELD('record_rowid':U). 
FOR EACH  Customer  
    WHERE Customer.CustNum >= 1  
    AND   Customer.CustNum <= 10  
    NO-LOCK 
    BY customer.custNum: 
  hBuf:BUFFER-CREATE(). 
  ASSIGN hParentNodeKey:BUFFER-VALUE = pcParentNodeKey 
         hNodeKey:BUFFER-VALUE       = STRING(Customer.CustNum,"999999":U) 
         hNodeLabel:BUFFER-VALUE     = STRING(Customer.CustNum) + " (" + 
TRIM(Customer.NAME) + ")" 
         hRecordRef:BUFFER-VALUE     = TRIM(STRING(Customer.CustNum)) 
         hRecordRowid:BUFFER-VALUE   = ROWID(Customer) 
         hPrivateData:BUFFER-VALUE   = pcPrimarySDO. 
END. 
END PROCEDURE. 

Parameters
pcParentNodeKey

If the node level being created is a child of another node, this parameter will contain the unique identifier of its parent node. If the node being created is the Root node, it will be blank. This value must be assigned to the new record’s parent_node_key to ensure that the build routine knows where to put this node.

pcPrimarySDO

Since an SDV needs a data source—normally in an SDO you must tell it what SDO is to be launched to allow this functionality. This SDO must contain the tables used in your extraction procedure and must have—as the first table in its query—the table whose ROWID was stored in the record_rowid field. This value can be assigned to the private_data field of the new record being created.

pcFilterValue

If a filter viewer is used on your dynamic TreeView the value being passed from the filter viewer will be received through this parameter. You must dissect this field if you want to use these values in your query.

phTable

This is the temp-table’s handle used to populate the TreeView with its nodes. You can use this handle to query any existing records in the TreeView as well as adding new records for nodes to be created. If your extract procedure is not the root node in the dynamic TreeView, you must find the parent node record using the pcParentNodeKey value. You either get the value from the record_ref field, which is the table’s key field, or use the record_rowid to find your parent record and the only filter on its values when building its child nodes.

As you can see from the example provided, you must populate the following fields:

Caution: When assigning the value of the record_ref field, you must make sure that you specify the value of the entity key field/entity object field as specified in gsc_entity_mnemonic table. If you do not, an incorrect record in the SDO is selected. When creating a node record, be sure that you specify a valid SDO name in the Primary SDO field to accompany your extract program.

Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095